package com.example.skyline.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/web/**")
                .excludePathPatterns("/verification/**")
                .excludePathPatterns("/upload/**")
                .excludePathPatterns("/log")
                .excludePathPatterns("/video/play/**")
                .excludePathPatterns("/video/stream/**")
                .excludePathPatterns("/video/stop/**")

                .excludePathPatterns("/upload/**")
                .excludePathPatterns("/address/export") // 设备管理导出
                .excludePathPatterns("/address/import") // 设备管理导入
                .excludePathPatterns("/UserManagement/**") // 设备管理导入模板下载
        ;
        super.addInterceptors(registry);
    }


    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }

}
